package cn.mumzone.pos.presenter;

import cn.mumzone.basic.mvp.AbsPresenter;
import cn.mumzone.basic.net.http.callback.ApiCallBack;
import cn.mumzone.basic.net.response.BaseResponse;
import cn.mumzone.basic.net.response.PageListResponse;
import cn.mumzone.pos.AppConstants;
import cn.mumzone.pos.model.TransactionRecordEntity;
import cn.mumzone.pos.model.source.MemberRepository;
import cn.mumzone.pos.presenter.contract.TransactionRecordContract;

/**
 * Created by qiuzhenhuan on 2019/8/14.
 */

public class TransactionRecordPresenter extends AbsPresenter<TransactionRecordContract.View, MemberRepository>
        implements TransactionRecordContract.Presenter {


    @Override
    public void loadRecordList(final boolean isRefresh, String type, String memberId, String dateTime, String pageNum) {

        ApiCallBack<PageListResponse<TransactionRecordEntity>> callBack = new ApiCallBack<PageListResponse<TransactionRecordEntity>>() {
            @Override
            public void onSuccess(PageListResponse<TransactionRecordEntity> response) {
                mView.showRecordList(response.getList(),isRefresh);
            }

            @Override
            public void onError(BaseResponse response) {
                mView.showError(response.getMsg());
            }
        };
        mRepo.selectTransactionRecord(type, memberId, dateTime, pageNum, String.valueOf(AppConstants.PAGE_SIZE), callBack);
        addSubscrebe(callBack);
    }
}
